package io.xccit.race.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import io.xccit.common.annotation.Log;
import io.xccit.common.core.controller.BaseController;
import io.xccit.common.core.domain.AjaxResult;
import io.xccit.common.enums.BusinessType;
import io.xccit.race.domain.RaceUniversity;
import io.xccit.race.service.IRaceUniversityService;
import io.xccit.common.utils.poi.ExcelUtil;
import io.xccit.common.core.page.TableDataInfo;

/**
 * 高校信息Controller
 * 
 * @author xccit
 * @date 2025-10-8
 */
@RestController
@RequestMapping("/race/university")
public class RaceUniversityController extends BaseController
{
    @Autowired
    private IRaceUniversityService raceUniversityService;

    /**
     * 查询高校信息列表
     */
    @PreAuthorize("@ss.hasPermi('race:university:list')")
    @GetMapping("/list")
    public TableDataInfo list(RaceUniversity raceUniversity)
    {
        startPage();
        List<RaceUniversity> list = raceUniversityService.selectRaceUniversityList(raceUniversity);
        return getDataTable(list);
    }

    /**
     * 导出高校信息列表
     */
    @PreAuthorize("@ss.hasPermi('race:university:export')")
    @Log(title = "高校信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RaceUniversity raceUniversity)
    {
        List<RaceUniversity> list = raceUniversityService.selectRaceUniversityList(raceUniversity);
        ExcelUtil<RaceUniversity> util = new ExcelUtil<RaceUniversity>(RaceUniversity.class);
        util.exportExcel(response, list, "高校信息数据");
    }

    /**
     * 获取高校信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('race:university:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(raceUniversityService.selectRaceUniversityById(id));
    }

    /**
     * 新增高校信息
     */
    @PreAuthorize("@ss.hasPermi('race:university:add')")
    @Log(title = "高校信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RaceUniversity raceUniversity)
    {
        return toAjax(raceUniversityService.insertRaceUniversity(raceUniversity));
    }

    /**
     * 修改高校信息
     */
    @PreAuthorize("@ss.hasPermi('race:university:edit')")
    @Log(title = "高校信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RaceUniversity raceUniversity)
    {
        return toAjax(raceUniversityService.updateRaceUniversity(raceUniversity));
    }

    /**
     * 删除高校信息
     */
    @PreAuthorize("@ss.hasPermi('race:university:remove')")
    @Log(title = "高校信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(raceUniversityService.deleteRaceUniversityByIds(ids));
    }
}
